package com.arelikebrothers.demo.java8.date;

import java.time.LocalDate;
import java.time.temporal.Temporal;
import java.time.temporal.TemporalAdjuster;

/**
 * Created by qiuzhongrun on 03/05/2017.
 */
public class CustomTemporalAdjuster implements TemporalAdjuster {

    @Override
    public Temporal adjustInto(Temporal temporal) {
        LocalDate localDate = LocalDate.from(temporal);
        int day = localDate.getDayOfMonth();
        if (day % 2 == 0) {
            localDate = localDate.plusDays(1);
        } else {
            localDate = localDate.plusDays(2);
        }

        return temporal.with(localDate);
    }
}
